package com.abing.strategy.factory;


import com.abing.strategy.enums.PayChannelEnum;
import com.abing.strategy.strategy.PayStrategy;
import com.abing.utils.SpringContextUtil;

/**
 * @date 2019/5/821:16
 */
public class StrategyFactory {
    // 使用策略工厂获取具体策略实现

    public static PayStrategy getPayStrategy(String name) {
        try {
            // 1.获取具体的策略class地址
            String className = PayChannelEnum.getBeanId(name);
            return (PayStrategy) SpringContextUtil.getBean(className);
        } catch (Exception e) {
            return null;
        }
    }


}
